import { reqPostSubmit } from '@/api/educational-training/online-examination'

const store = {
  state: {
    // 线上考试
    examDetailList: [],
    currentPaperIndex: 0,
    // 统计
    staticDetail: {},
  },
  mutations: {
    clearStore(state) {
      state.currentPaperIndex = 0
      state.examDetailList = []
    },
    setCurrentPaperIndex(state, data) {
      state.currentPaperIndex = data
    },
    setExamDetailList(state, data) {
      state.examDetailList = data
    },
    onlineExamSetStaticDetail(state, data) {
      state.staticDetail = data
    },
    setExamDetailListItem(state, data) {
      state.examDetailList.splice(state.currentPaperIndex, 1, data)
    }
  },
  actions: {
    submitPapel({ state }, data) {
      return reqPostSubmit({
        detailList: state.examDetailList,
        ...data
      })
    },
  },
  getters: {}
}

export default store
